import { AddFriendRequest, AddFriendResponse } from '@entity/add_user';
import { SystemAddFriendMsg, SystemMsg } from '@entity/system_msg';
import { User } from '@entity/user';
import { Component, Prop, Vue } from 'vue-property-decorator';
import SystemMsgModel from '@message/system/model/Index.vue';
import axios from '@axios/websocket'

@Component({
    components: {
        SystemMsgModel
    }
})
export class AddFriendRequestView extends Vue {

    /** 系统消息 */
    @Prop({
        default: () => new SystemMsg()
    })
    private msg: SystemMsg;

    /** 是否显示对话框 */
    private display: boolean = false;

    /** 
     * 获取系统消息中的好友申请信息
     */
    private get systemMsg(): SystemAddFriendMsg<AddFriendRequest> {
        return this.msg.data;
    }

    /** 
     * 获取申请
     */
    private get request(): AddFriendRequest {
        return this.systemMsg.data;
    }

    /** 
     * 处理申请, 做出反馈
     */
    private doResponse(flag: boolean) {
        let user: User = this.$store.getters.user(this.systemMsg.userId);
        let response: AddFriendResponse = new AddFriendResponse(this.request.id, this.request.name, flag)
        axios.add.response(user, response);
    }

}